package leecode

type MyCalendar struct {
	events []Event
}

type Event struct {
	start, end int
}

func Constructor729() MyCalendar {
	return MyCalendar{}
}

func (this *MyCalendar) Book(start int, end int) bool {
	newEvent := Event{start, end}
	for _, event := range this.events {
		if (start < event.end && start >= event.start) || (end > event.start && end <= event.end) || (start <= event.start && end >= event.end) {
			// 如果新事件与现有事件有交叉，则返回false
			return false
		}
	}
	// 如果没有交叉，则将新事件加入日程表
	this.events = append(this.events, newEvent)
	return true
}
